USE [RD_GLMart]
GO
/****** Object:  StoredProcedure [dbo].[UE_GL_JDEABM_aupd]    Script Date: 5/30/13 1:04:49 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER OFF
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[UE_GL_JDEABM_aupd]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'------------------------------------------------------------------------------------------------------------------------------------------------------------
--	Author:			c Copyright 2004 Andrews Consulting Group 
--	Procedure:		UE_GL_JDEABM_aupd
--
--	Description:		User Exit To Maintain GL_Star_SubLedger Dimension
--				This User Exit Will Be Applied to the JDEABAddressBookMaster Table	
--				And Will Fire on Update and maintain the SubLedgerDescription Field
--
--	Application:		User Exit to Maintain GL_Star_SubLedger
--
--
--Modification History
--
--Date			Modified By		Description
--01.01.2001 		<developer name>	<comments>
------------------------------------------------------------------------------------------------------------------------------------------------------------

CREATE        PROCEDURE [dbo].[UE_GL_JDEABM_aupd]

@Entry int, 
@SuccessInd int OUTPUT,
@RtnMessage varchar(50) OUTPUT,
@SelectInd int OUTPUT
AS

/*
--BEGIN:  Reference purposes @Entry points
BEFORE_CLEAR    ( 1)
AFTER_CLEAR     ( 2)
BEFORE_INSERT   ( 3)
AFTER_INSERT    ( 4)
BEFORE_UPDATE   ( 5)
AFTER_UPDATE    ( 6)
BEFORE_DELETE   ( 7)
AFTER_DELETE    ( 8)
BEFORE_REFRESH  ( 9)
AFTER_REFRESH   (10)
BEFORE_STARTUP  (11)
AFTER_STARTUP   (12)
--END:  Reference purposes @Entry points
*/

DECLARE
	@temp int

SELECT @SuccessInd = 1
SELECT @SelectInd = 0
SELECT @RtnMessage = ''Nothing''

--Variables declared for use w/in this stored procedure
DECLARE @Updateperiod numeric (5)
DECLARE @Beforeperiod numeric (5)
DECLARE @Company char(5)
DECLARE @MSG char (255)
DECLARE @SourceID INT

/*****************************************************************************************/
/**********                	Before Clear 					**********/
/*****************************************************************************************/
--IF (@Entry = 1)
--BEGIN	
--	exec master.dbo.xp_logevent 65000,''UE Ran Entry 1'',Informational
--END
/*****************************************************************************************/
/**********                	After Clear 					**********/
/*****************************************************************************************/
--IF (@Entry = 2)
--BEGIN	
--	exec master.dbo.xp_logevent 65000,''UE Ran Entry 2'',Informational
--END
/*****************************************************************************************/
/**********                	Before Insert 					**********/
/*****************************************************************************************/
--IF (@Entry = 3)
--BEGIN		
--	exec master.dbo.xp_logevent 65000,''UE Ran Entry 3'',Informational
--END
/*****************************************************************************************/
/**********                	After Insert 					**********/
/*****************************************************************************************/
--IF (@Entry = 4) 
--	exec master.dbo.xp_logevent 65000,''UE Ran Entry 4'',Informational
--END
/*****************************************************************************************/
/**********                	Before Update 					**********/
/*****************************************************************************************/
--IF (@Entry = 5)
--BEGIN	
--	exec master.dbo.xp_logevent 65000,''UE Ran Entry 5'',Informational
--END
/*****************************************************************************************/
/**********                	After Update 					**********/
/*****************************************************************************************/
IF (@Entry = 6)
BEGIN	


UPDATE
	RD_GLMart.dbo.GL_Star_Subledger
SET 
	SubLedgerDescription = UE_Update.AlphaName
FROM
	RD_GLMart.dbo.GL_Star_Subledger SL
	INNER JOIN 
	RD_GLWork.dbo.UEtbl_GL_JDEABM_aupd UE_Update ON
		SL.Subledger = UE_Update.AddressNumber AND 
		SL.SourceID = UE_Update.SourceID
WHERE			
	SL.SubLedgerType = ''A''



END
/*****************************************************************************************/
/**********                	Before Delete 					**********/
/*****************************************************************************************/
--IF (@Entry = 7)
--BEGIN	
--	exec master.dbo.xp_logevent 65000,''UE Ran Entry 7'',Informational
--END
/*****************************************************************************************/
/**********                	After Delete 					**********/
/*****************************************************************************************/
--IF (@Entry = 8)
--BEGIN	
--	exec master.dbo.xp_logevent 65000,''UE Ran Entry 8'',Informational
--END
/*****************************************************************************************/
/**********                	Before Refresh 					**********/
/*****************************************************************************************/
--IF (@Entry = 9)
--BEGIN	
--	exec master.dbo.xp_logevent 65000,''UE Ran Entry 9'',Informational
--END
/*****************************************************************************************/
/**********                	After Refresh 					**********/
/*****************************************************************************************/
--IF (@Entry = 10)
--BEGIN	
--	exec master.dbo.xp_logevent 65000,''UE Ran Entry 10'',Informational
--END
/*****************************************************************************************/
/**********                	Before Startup 					**********/
/*****************************************************************************************/
--IF (@Entry = 11)
--BEGIN	
--	exec master.dbo.xp_logevent 65000,''UE Ran Entry 11'',Informational
--END
/*****************************************************************************************/
/**********                	After Startup 					**********/
/*****************************************************************************************/
--IF (@Entry = 12)
--BEGIN	
--	exec master.dbo.xp_logevent 65000,''UE Ran Entry 12'',Informational
--END
/* END of stored procedure */

/******************************************************************************************/
/*************  Need to fix the Catageory code descritpions because of a Datamirror Bug  **/
/******************************************************************************************/
' 
END
GO
/****** Object:  StoredProcedure [dbo].[USP_CheckForInvalidSubLedgerTypes]    Script Date: 5/30/13 1:04:49 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER OFF
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[USP_CheckForInvalidSubLedgerTypes]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE     PROCEDURE [dbo].[USP_CheckForInvalidSubLedgerTypes] AS
-----------------------------------------------------------------------------------------------------------------------------
--	Author:			c Copyright 2004 Andrews Consulting Group 
--	Procedure:		USP_CheckForInvalidSubLedgerTypes
--
--	Description:		User Stored Procedure To Validate The Sub Ledger Dimension
--				This User Stored Procedure Must Be Executed After Refresh Of The Mart
--
--	Application:		Check For Valid Sub Ledger Types
--
--
--Modification History
--
--Date			Modified By		Description
-----------------------------------------------------------------------------------------------------------------------------
DECLARE @@TABNAME 	VARCHAR(30)
DECLARE @@USERNAME 	VARCHAR(30)
DECLARE @@SUBJECT 		VARCHAR(255)
DECLARE @@Query		VARCHAR(255)
DECLARE @@EMailList		VARCHAR(512)
DECLARE @@UseEmail	nchar(5)
DECLARE @@UseMsg	nchar(5)

SET @@EMailList = ''user@usercompany.com''
SET @@UseEmail	= ''False''
SET @@UseMsg	= ''True''


-----------------------------------------------------------------------------------------------------------------------------
-- Validate SubLedger Codes Of A, C or Blank
-----------------------------------------------------------------------------------------------------------------------------

IF 
	EXISTS(
		SELECT * FROM GL_Star_Subledger
			WHERE SubLedgerType NOT IN ('''',''A'',''C'')
			) 
BEGIN

	SET	@@TABNAME	= ''GL_Star_Subledger''
	SET	@@SUBJECT	= ''Records with SubLedger Type(s) other than A, C,  or blank have been added to the '' + @@TABNAME + '' table.''
	
	IF @@UseMsg = ''True''
	BEGIN
		EXEC	master.dbo.xp_logevent 60000, @@SUBJECT, informational
	END
	
	IF @@UseEmail = ''True''
	BEGIN
	EXEC master.dbo.xp_sendmail @recipients = @@EmailList, 
		@query = ''	SELECT * FROM GL_Star_Subledger
			WHERE SubLedgerType NOT IN (" ","A","C") ORDER BY SubLedgerType'',
			@subject = @@SUBJECT,
			@message = ''The GL_Mart has Sub Ledger Records Other Than A, C or blank. Please investigate.''
				
	END

END
' 
END
GO
/****** Object:  StoredProcedure [dbo].[USP_GL_Star_FactDetail]    Script Date: 5/30/13 1:04:49 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER OFF
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[USP_GL_Star_FactDetail]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE       PROCEDURE [dbo].[USP_GL_Star_FactDetail] AS
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
--	Author:			c Copyright 2004 Andrews Consulting Group 
--	Procedure:		USP_GL_Star_FactDetail
--
--	Description:		User Stored Procedure To Update The GL_Star_SubLedger Table
--				Stored Procedure Must Be Executed After Refresh Of The Star_FactDetail
--				Table. 
--
--	Application:		After Refresh Procedure For GL_Star_Subledger
--
--
--Modification History
--
--Date			Modified By		Description
--01.01.2001 		<developer name>	<comments>
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

TRUNCATE TABLE RD_GLMart.dbo.GL_Star_Subledger
INSERT RD_GLMart.dbo.GL_Star_Subledger 
		SELECT DISTINCT
			'' '',
			FD.SOURCEID,
			FD.SubLedger,
			FD.SubLedgerType,
			'' '',
			'' '',
			FD.SOURCE,
			0,
			''1900/01/01'',
			0,
			''1900/01/01'',
			0,
			''1900/01/01'',
			''1900/01/01''
		FROM 
			RD_GLMart.dbo.GL_Star_FactsDetails FD

UPDATE RD_GLMart.dbo.GL_Star_Subledger 
	SET SubLedgerDescription = AB.AlphaName
FROM 	RD_GLMart.dbo.GL_Star_Subledger SL 
INNER JOIN RD_CommonWork.dbo.JDEABAddressbookmaster AB ON 
	SL.Subledger = AB.AddressNumber AND 
	SL.SourceID = AB.SourceID
WHERE SL.SubLedgerType = ''A''



UPDATE RD_GLMart.dbo.GL_Star_Subledger 
	SET SubLedgerDescription = BUM.BusinessUnit
FROM 	RD_GLMart.dbo.GL_Star_Subledger SL 
INNER JOIN RD_Common.dbo.Star_BusinessUnit  BUM ON 
(RTRIM(LTRIM(SL.Subledger)) = RTRIM(LTRIM(BUM.BusinessUnitCode))) AND 
	SL.SourceID = BUM.SourceID
WHERE SL.SubLedgerType = ''C''
' 
END
GO
/****** Object:  StoredProcedure [dbo].[USP_Load_Orphans_GL]    Script Date: 5/30/13 1:04:49 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER OFF
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[USP_Load_Orphans_GL]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
--	Author:			c Copyright 2004 Andrews Consulting Group 
--	Procedure:		USP_LOAD_ORPHANS_GL
--
--	Description:	User Stored Procedure To Populate the table
--					storing orphans.
--						
--
--	Application:	Load Orphans table
--
--
--Modification History
--Date				Modified By			Description
--08.18.2006		Craig Scott			Created.
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

CREATE    PROCEDURE [dbo].[USP_Load_Orphans_GL] @DateRun DATETIME
AS
BEGIN
	-- SET NOCOUNT ON added to prevent extra result sets from
	-- interfering with SELECT statements.
	SET NOCOUNT ON;
	-- Clear the table of any previous records for this mart
	-- then load it again for a one time run.
	--DELETE FROM RD_COMMON.DBO.ORPHANS WHERE vchMart = ''GLMART''

	INSERT RD_COMMON.DBO.ORPHANS
	SELECT DISTINCT ''GLMART'', @DateRun, ''Facts Account'',T1.ACCOUNT, COUNT(T1.Account)
	FROM RD_GLMART.DBO.GL_Star_Facts T1
    LEFT JOIN RD_GLMART.DBO.GL_Star_Account T2
    ON T1.Account = T2.Account
	and T1.Sourceid = T2.SourceId
    WHERE T2.SourceId is null
	GROUP BY T1.Account

	INSERT RD_COMMON.DBO.ORPHANS
	SELECT DISTINCT ''GLMART'',@DateRun,''Facts Business'',T1.BusinessUnitCode,COUNT(T1.BusinessUnitCode)
	FROM RD_GLMART.DBO.GL_Star_Facts T1
    LEFT JOIN RD_Common.dbo.Star_BusinessUnit T2
    ON  T1.BusinessUnitCode = T2.BusinessUnitCode
	and T1.Sourceid = T2.SourceId
    WHERE T2.SourceId is null
	GROUP BY T1.BusinessUnitCode

	INSERT RD_COMMON.DBO.ORPHANS
	SELECT DISTINCT ''GLMART'',@DateRun,''Facts Company'',T1.CompanyNumber,COUNT(T1.CompanyNumber)
	FROM RD_GLMART.DBO.GL_Star_Facts T1
    LEFT JOIN RD_Common.dbo.Star_Company T2
    ON T1.CompanyNumber = T2.CompanyNumber
	and T1.Sourceid = T2.SourceId
    WHERE T2.SourceId is null
	GROUP BY T1.CompanyNumber

	INSERT RD_COMMON.DBO.ORPHANS
	SELECT DISTINCT ''GLMART'', @DateRun,''Facts FiscalYear'',T1.FiscalYear,COUNT(T1.FiscalYear)
	FROM RD_GLMART.DBO.GL_Star_Facts T1
    LEFT JOIN RD_COMMON.DBO.Star_FiscalYear T2
    ON T1.FiscalYear = T2.FiscalYear 
	and T1.Sourceid = T2.SourceId
    WHERE T2.SourceId is null and
    T2.FiscalDatePattern = ''R''
	GROUP BY T1.FiscalYear	

	INSERT RD_COMMON.DBO.ORPHANS
	SELECT DISTINCT ''GLMART'',@DateRun,''Facts Ledger'',T1.SubLedgerID,COUNT(T1.SubLedgerID)
	FROM RD_GLMART.DBO.GL_Star_Facts T1
    LEFT JOIN RD_GLMART.DBO.GL_Star_Ledger	 T2
    ON T1.SubLedgerID = T2.LedgerTypeCode
	and T1.Sourceid = T2.SourceId
    WHERE T2.SourceId is null 
	GROUP BY T1.SubLedgerID

	INSERT RD_COMMON.DBO.ORPHANS
	SELECT DISTINCT ''GLMART'',@DateRun,''Facts SUBLEDGER'',T1.SubLedgerID,COUNT(T1.SubLedgerID)
	FROM RD_GLMART.DBO.GL_Star_Facts T1
    LEFT JOIN RD_GLMART.DBO.GL_Star_SubLedger	 T2
    ON T1.Sourceid = T2.SourceId and
	T1.SubLedgerType = T2.SubLedgerType
    WHERE T2.SourceId is null
	GROUP BY T1.SubLedgerID

	INSERT RD_COMMON.DBO.ORPHANS
	SELECT DISTINCT ''GLMART'',@DateRun,''FactsDetails ACCOUNT'',T1.Account,COUNT(T1.Account)
	FROM RD_GLMART.DBO.GL_Star_FactsDetails T1
    LEFT JOIN RD_GLMART.DBO.GL_Star_Account T2
    ON T1.Account = T2.Account
	and T1.Sourceid = T2.SourceId
    WHERE T2.SourceId is null
	GROUP BY T1.Account

	INSERT RD_COMMON.DBO.ORPHANS
	SELECT DISTINCT ''GLMART'',@DateRun,''FactsDetails BusinessUnit'',T1.BusinessUnitCode,COUNT(T1.BusinessUnitCode)
	FROM RD_GLMART.DBO.GL_Star_FactsDetails T1
    LEFT JOIN RD_Common.dbo.Star_BusinessUnit T2
    ON T1.BusinessUnitCode = T2.BusinessUnitCode
	and T1.Sourceid = T2.SourceId
    WHERE T2.SourceId is null
	GROUP BY T1.BusinessUnitCode

	INSERT RD_COMMON.DBO.ORPHANS
	SELECT DISTINCT ''GLMART'',@DateRun,''FactsDetails Company'',T1.CompanyNumber,COUNT(T1.CompanyNumber)
	FROM RD_GLMART.DBO.GL_Star_FactsDetails T1
    LEFT JOIN RD_Common.dbo.Star_Company T2
    ON T1.CompanyNumber = T2.CompanyNumber
	and T1.Sourceid = T2.SourceId
    WHERE T2.SourceId is null
	GROUP BY T1.CompanyNumber

	INSERT RD_COMMON.DBO.ORPHANS
	SELECT DISTINCT ''GLMART'',@DateRun,''FactsDetails Ledger'',T1.SubLedgerID,COUNT(T1.SubLedgerID)
	FROM RD_GLMART.DBO.GL_Star_FactsDetails T1
    LEFT JOIN RD_GLMART.DBO.GL_Star_Ledger	 T2
    ON T1.SubLedgerID = T2.LedgerTypeCode
	and T1.Sourceid = T2.SourceId
    WHERE T2.SourceId is null 
	GROUP BY T1.SubLedgerID

	INSERT RD_COMMON.DBO.ORPHANS
	SELECT DISTINCT ''GLMART'',@DateRun,''FactsDetails GLDateID'',T1.GLDateID,COUNT(T1.GLDateID)
	FROM RD_GLMART.DBO.GL_Star_FactsDetails T1
    LEFT JOIN RD_GLMART.DBO.GL_Star_Dates T2
    ON T1.GLDateID = T2.CompanyDateID 
    WHERE T2.CompanyDateID is null 
	GROUP BY T1.GLDateID


END
' 
END
GO
/****** Object:  Table [dbo].[GL_Star_Facts]    Script Date: 5/30/13 1:04:49 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[GL_Star_Facts]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[GL_Star_Facts](
	[CompanyNumberID] [bigint] NOT NULL,
	[BusinessUnitID] [char](20) NOT NULL,
	[AIDID] [bigint] NOT NULL,
	[AccountID] [char](20) NOT NULL,
	[SubLedgerID] [char](15) NOT NULL,
	[LedgerTypeID] [char](10) NOT NULL,
	[FiscalYearID] [bigint] NOT NULL,
	[SourceID] [int] NOT NULL,
	[AID] [char](8) NOT NULL,
	[FiscalYear] [int] NOT NULL,
	[Account] [char](15) NOT NULL,
	[LedgerTypeCode] [char](2) NOT NULL,
	[Object] [char](6) NOT NULL,
	[Subsidiary] [char](8) NOT NULL,
	[CompanyNumber] [char](5) NOT NULL,
	[BusinessUnitCode] [char](12) NOT NULL,
	[SubLedger] [char](8) NOT NULL,
	[SubLedgerType] [char](1) NOT NULL,
	[CurrentMTD] [decimal](20, 7) NOT NULL,
	[CurrentYTD] [decimal](20, 7) NOT NULL,
	[PriorYearCloseBalance] [decimal](20, 7) NOT NULL,
	[NetPosting01] [decimal](20, 7) NOT NULL,
	[Balance01] [decimal](20, 7) NOT NULL,
	[NetPosting02] [decimal](20, 7) NOT NULL,
	[Balance02] [decimal](20, 7) NOT NULL,
	[NetPosting03] [decimal](20, 7) NOT NULL,
	[Balance03] [decimal](20, 7) NOT NULL,
	[NetPosting04] [decimal](20, 7) NOT NULL,
	[Balance04] [decimal](20, 7) NOT NULL,
	[NetPosting05] [decimal](20, 7) NOT NULL,
	[Balance05] [decimal](20, 7) NOT NULL,
	[NetPosting06] [decimal](20, 7) NOT NULL,
	[Balance06] [decimal](20, 7) NOT NULL,
	[NetPosting07] [decimal](20, 7) NOT NULL,
	[Balance07] [decimal](20, 7) NOT NULL,
	[NetPosting08] [decimal](20, 7) NOT NULL,
	[Balance08] [decimal](20, 7) NOT NULL,
	[NetPosting09] [decimal](20, 7) NOT NULL,
	[Balance09] [decimal](20, 7) NOT NULL,
	[NetPosting10] [decimal](20, 7) NOT NULL,
	[Balance10] [decimal](20, 7) NOT NULL,
	[NetPosting11] [decimal](20, 7) NOT NULL,
	[Balance11] [decimal](20, 7) NOT NULL,
	[NetPosting12] [decimal](20, 7) NOT NULL,
	[Balance12] [decimal](20, 7) NOT NULL,
	[NetPosting13] [decimal](20, 7) NOT NULL,
	[Balance13] [decimal](20, 7) NOT NULL,
	[NetPosting14] [decimal](20, 7) NOT NULL,
	[Balance14] [decimal](20, 7) NOT NULL,
	[RequestedBudget] [decimal](20, 7) NOT NULL,
	[ApprovedBudget] [decimal](20, 7) NOT NULL,
	[OriginalBeginningBudget] [decimal](20, 7) NOT NULL,
	[CurrencyCodeFrom] [char](3) NOT NULL,
	[CurrencyCodeIn] [char](3) NOT NULL,
	[Source] [char](20) NOT NULL,
	[ITDPriorYearCloseBalance] [decimal](20, 7) NOT NULL,
	[ITDBalance01] [decimal](20, 7) NOT NULL,
	[ITDBalance02] [decimal](20, 7) NOT NULL,
	[ITDBalance03] [decimal](20, 7) NOT NULL,
	[ITDBalance04] [decimal](20, 7) NOT NULL,
	[ITDBalance05] [decimal](20, 7) NOT NULL,
	[ITDBalance06] [decimal](20, 7) NOT NULL,
	[ITDBalance07] [decimal](20, 7) NOT NULL,
	[ITDBalance08] [decimal](20, 7) NOT NULL,
	[ITDBalance09] [decimal](20, 7) NOT NULL,
	[ITDBalance10] [decimal](20, 7) NOT NULL,
	[ITDBalance11] [decimal](20, 7) NOT NULL,
	[ITDBalance12] [decimal](20, 7) NOT NULL,
	[ITDBalance13] [decimal](20, 7) NOT NULL,
	[ITDBalance14] [decimal](20, 7) NOT NULL,
	[Century] [int] NOT NULL,
	[FiscalQuarter] [char](4) NOT NULL,
	[PriorYearEndNetPosting] [decimal](20, 7) NOT NULL,
	[WeekToDateNetPosting] [decimal](20, 7) NOT NULL,
	[MemoBudgetChange] [decimal](20, 7) NOT NULL,
	[PercentComplete] [decimal](20, 7) NOT NULL,
	[MemoCommitmentChanges] [decimal](20, 7) NOT NULL,
	[UserID] [char](10) NOT NULL,
	[ProgramID] [char](10) NOT NULL,
	[DateUpdated] [datetime] NOT NULL,
	[WorkStationID] [char](10) NOT NULL,
	[LastTimeUpdated] [int] NOT NULL,
	[BalanceForward] [decimal](20, 7) NOT NULL,
	[PurgeFlag] [char](1) NOT NULL,
	[NetDebitPosting01] [decimal](20, 7) NOT NULL,
	[NetDebitPosting02] [decimal](20, 7) NOT NULL,
	[NetDebitPosting03] [decimal](20, 7) NOT NULL,
	[NetDebitPosting04] [decimal](20, 7) NOT NULL,
	[NetDebitPosting05] [decimal](20, 7) NOT NULL,
	[NetDebitPosting06] [decimal](20, 7) NOT NULL,
	[NetDebitPosting07] [decimal](20, 7) NOT NULL,
	[NetDebitPosting08] [decimal](20, 7) NOT NULL,
	[NetDebitPosting09] [decimal](20, 7) NOT NULL,
	[NetDebitPosting10] [decimal](20, 7) NOT NULL,
	[NetDebitPosting11] [decimal](20, 7) NOT NULL,
	[NetDebitPosting12] [decimal](20, 7) NOT NULL,
	[NetDebitPosting13] [decimal](20, 7) NOT NULL,
	[NetDebitPosting14] [decimal](20, 7) NOT NULL,
	[InsertIndicator] [int] NOT NULL,
	[InsertDate] [datetime] NOT NULL,
	[ChangeIndicator] [int] NOT NULL,
	[ChangeDate] [datetime] NOT NULL,
	[DeleteIndicator] [int] NOT NULL,
	[DeleteDate] [datetime] NOT NULL,
	[PurgeDate] [datetime] NOT NULL,
 CONSTRAINT [PK_GL_Star_Facts] PRIMARY KEY CLUSTERED 
(
	[FiscalYear] ASC,
	[Account] ASC,
	[AID] ASC,
	[LedgerTypeCode] ASC,
	[BusinessUnitCode] ASC,
	[SubLedger] ASC,
	[SubLedgerType] ASC,
	[CurrencyCodeFrom] ASC,
	[CurrencyCodeIn] ASC,
	[SourceID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON, DATA_COMPRESSION = PAGE) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_PADDING OFF
GO
/****** Object:  Table [dbo].[GL_Star_FactsDetails]    Script Date: 5/30/13 1:04:49 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[GL_Star_FactsDetails]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[GL_Star_FactsDetails](
	[CompanyNumberID] [bigint] NOT NULL,
	[BusinessUnitID] [char](20) NOT NULL,
	[AIDID] [bigint] NOT NULL,
	[AccountID] [char](20) NOT NULL,
	[SubLedgerID] [char](15) NOT NULL,
	[LedgerTypeID] [char](10) NOT NULL,
	[SourceID] [int] NOT NULL,
	[DocumentCompany] [char](5) NOT NULL,
	[DocumentType] [char](2) NOT NULL,
	[DocumentNumber] [int] NOT NULL,
	[JournalEntryLineNumber] [numeric](20, 7) NOT NULL,
	[LineExtensionCode] [char](2) NOT NULL,
	[GLDateID] [bigint] NOT NULL,
	[AID] [char](8) NOT NULL,
	[Account] [char](15) NOT NULL,
	[LedgerTypeCode] [char](2) NOT NULL,
	[GLPostedCode] [char](1) NOT NULL,
	[BatchNumber] [int] NOT NULL,
	[BatchType] [char](2) NOT NULL,
	[BatchDateID] [bigint] NOT NULL,
	[CompanyNumber] [char](5) NOT NULL,
	[BusinessUnitCode] [char](12) NOT NULL,
	[Object] [char](6) NOT NULL,
	[Subsidiary] [char](8) NOT NULL,
	[SubLedger] [char](8) NOT NULL,
	[SubLedgerType] [char](1) NOT NULL,
	[Amount] [decimal](20, 7) NOT NULL,
	[Units] [decimal](20, 7) NOT NULL,
	[ReverseOrVoidEntry] [char](1) NOT NULL,
	[ExplanationDescription] [char](30) NOT NULL,
	[RemarkExplanation] [char](30) NOT NULL,
	[AddressNumber] [int] NOT NULL,
	[Source] [char](20) NOT NULL,
	[PaymentNumber] [char](8) NOT NULL,
	[CheckDateID] [bigint] NOT NULL,
	[InvoiceNumber] [char](25) NOT NULL,
	[InvoiceDateID] [bigint] NOT NULL,
	[PONumber] [char](8) NOT NULL,
	[OrderTypeCode] [char](2) NOT NULL,
	[JobType] [char](6) NOT NULL,
	[JobStep] [char](4) NOT NULL,
	[BatchSystemDateID] [bigint] NOT NULL,
	[BatchTime] [int] NOT NULL,
	[AccountNumber] [char](29) NOT NULL,
	[AccountMode01] [char](1) NOT NULL,
	[GLPeriodNumber] [int] NOT NULL,
	[Century] [int] NOT NULL,
	[FiscalYear] [int] NOT NULL,
	[FiscalQuarter] [char](4) NOT NULL,
	[CurrencyCode] [char](3) NOT NULL,
	[CurrencyConversionRateSpot] [decimal](20, 7) NOT NULL,
	[HistoricalExchangeRate] [decimal](20, 7) NOT NULL,
	[HistoricalDateID] [bigint] NOT NULL,
	[UnitOfMeasure] [char](2) NOT NULL,
	[GLOffset] [char](4) NOT NULL,
	[Ref1JEVouchInvEtc] [char](8) NOT NULL,
	[Ref2AddressNumber] [char](8) NOT NULL,
	[Ref3AccountReconciliation] [char](8) NOT NULL,
	[PayItem] [char](3) NOT NULL,
	[OriginalDocumentNumber] [int] NOT NULL,
	[OriginalDocumentType] [char](2) NOT NULL,
	[OriginalPayItem] [char](3) NOT NULL,
	[PurchaseOrderDocumentCompany] [char](5) NOT NULL,
	[OriginalOrderDocumentCompany] [char](5) NOT NULL,
	[PurchaseOrderDocumentType] [char](2) NOT NULL,
	[CheckClearedDateID] [bigint] NOT NULL,
	[SerialNumber] [char](25) NOT NULL,
	[BatchRearEndPostedCode] [char](1) NOT NULL,
	[Reconciled] [char](1) NOT NULL,
	[SummarizedCode] [char](1) NOT NULL,
	[PurgeCode] [char](1) NOT NULL,
	[FlagFor1099] [char](1) NOT NULL,
	[AlternateGLPostingCode1] [char](1) NOT NULL,
	[AlternateGLPostingCode2] [char](1) NOT NULL,
	[AlternateGLPostingCode3] [char](1) NOT NULL,
	[AlternateGLPostingCode4] [char](1) NOT NULL,
	[MultiCurrencyJournalEntry] [char](1) NOT NULL,
	[CashBasisAccountingPostCode] [char](1) NOT NULL,
	[CommitmentReliefFlag] [char](1) NOT NULL,
	[BillingControl] [char](1) NOT NULL,
	[CurrencyUpdate] [char](1) NOT NULL,
	[LaborCostingFlag] [char](1) NOT NULL,
	[FutureUseFlag11] [char](1) NOT NULL,
	[FutureUseFlag12] [char](1) NOT NULL,
	[FutureUseFlag13] [char](1) NOT NULL,
	[FutureUseFlag14] [char](1) NOT NULL,
	[ConsumptionTaxCrossReference] [char](1) NOT NULL,
	[FutureUseFlag16] [char](1) NOT NULL,
	[DeleteNotAllowed] [char](1) NOT NULL,
	[FutureUseFlag18] [char](1) NOT NULL,
	[FutureUseFlag19] [char](1) NOT NULL,
	[LeaseCostLedgerPostedCode] [char](1) NOT NULL,
	[BillCode] [char](1) NOT NULL,
	[Phase] [char](4) NOT NULL,
	[PurchaseOrderSuffix] [char](3) NOT NULL,
	[LineNumber] [decimal](20, 7) NOT NULL,
	[FiscalYearWeekly] [int] NOT NULL,
	[FiscalPeriodWeekly] [int] NOT NULL,
	[ClosedStatement] [char](1) NOT NULL,
	[OperationsSequenceNumber] [decimal](20, 7) NOT NULL,
	[HomeBusinessUnit] [char](12) NOT NULL,
	[DOISub] [int] NOT NULL,
	[OutsiderLeaseWellID] [char](25) NOT NULL,
	[IDType] [char](2) NOT NULL,
	[ServiceDateTaxID] [bigint] NOT NULL,
	[TransactionOriginator] [char](10) NOT NULL,
	[RegistrationNumber] [int] NOT NULL,
	[InternalPaymentID] [decimal](15, 0) NOT NULL,
	[UserID] [char](10) NOT NULL,
	[ProgramID] [char](10) NOT NULL,
	[WorkStationID] [char](10) NOT NULL,
	[DateUpdatedID] [bigint] NOT NULL,
	[LastTimeUpdated] [int] NOT NULL,
	[ManagerialAnalysisCode1] [char](12) NOT NULL,
	[ManagerialAnalysisCode2] [char](12) NOT NULL,
	[ManagerialAnalysisCode3] [char](12) NOT NULL,
	[ManagerialAnalysisCode4] [char](12) NOT NULL,
	[ManagerialAnalysisType1] [char](1) NOT NULL,
	[ManagerialAnalysisType2] [char](1) NOT NULL,
	[ManagerialAnalysisType3] [char](1) NOT NULL,
	[ManagerialAnalysisType4] [char](1) NOT NULL,
	[ItemNumberShort] [int] NOT NULL,
	[PostingCode1ManagerialAccount] [char](1) NOT NULL,
	[PostingCode2ManagerialAccount] [char](1) NOT NULL,
	[PostingCode3ManagerialAccount] [char](1) NOT NULL,
	[PostingCode4ManagerialAccount] [char](1) NOT NULL,
	[PostingCode5ManagerialAccount] [char](1) NOT NULL,
	[PostingCode6ManagerialAccount] [char](1) NOT NULL,
	[PostingCode7ManagerialAccount] [char](1) NOT NULL,
	[PostingCode8ManagerialAccount] [char](1) NOT NULL,
	[PostingCode9ManagerialAccount] [char](1) NOT NULL,
	[PostingCode10ManagerialAccount] [char](1) NOT NULL,
	[CurrencyCodeBase] [char](3) NOT NULL,
	[CurrencyModeForeignDomEntry] [char](1) NOT NULL,
	[PurgeFlag] [char](1) NOT NULL,
	[TaxRateArea] [char](10) NOT NULL,
	[TaxExplCode1] [char](2) NOT NULL,
	[TaxShortItemNumber] [int] NOT NULL,
	[ActivityBasedCostingActyCode] [char](10) NOT NULL,
	[FutureUseFlag] [char](1) NOT NULL,
	[CurrencyAmount] [decimal](20, 7) NOT NULL,
	[DistributionLineNumber] [decimal](20, 7) NOT NULL,
	[ReceiptNumber] [char](25) NOT NULL,
	[InsertIndicator] [int] NOT NULL,
	[InsertDate] [datetime] NOT NULL,
	[ChangeIndicator] [int] NOT NULL,
	[ChangeDate] [datetime] NOT NULL,
	[DeleteIndicator] [int] NOT NULL,
	[DeleteDate] [datetime] NOT NULL,
	[PurgeDate] [datetime] NOT NULL,
 CONSTRAINT [PK_GL_Star_FactsDetails] PRIMARY KEY CLUSTERED 
(
	[DocumentCompany] ASC,
	[DocumentType] ASC,
	[DocumentNumber] ASC,
	[JournalEntryLineNumber] ASC,
	[LineExtensionCode] ASC,
	[GLDateID] ASC,
	[LedgerTypeCode] ASC,
	[SourceID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON, FILLFACTOR = 90, DATA_COMPRESSION = PAGE) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_PADDING OFF
GO
/****** Object:  Table [dbo].[GL_Star_SubLedger]    Script Date: 5/30/13 1:04:49 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[GL_Star_SubLedger]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[GL_Star_SubLedger](
	[SubLedgerID] [char](15) NOT NULL,
	[SourceID] [int] NOT NULL,
	[SubLedger] [char](8) NOT NULL,
	[SubLedgerType] [char](1) NOT NULL,
	[SubLedgerTypeDescription] [char](30) NOT NULL,
	[SubLedgerDescription] [char](40) NOT NULL,
	[Source] [char](20) NOT NULL,
	[InsertIndicator] [int] NOT NULL,
	[InsertDate] [datetime] NOT NULL,
	[ChangeIndicator] [int] NOT NULL,
	[ChangeDate] [datetime] NOT NULL,
	[DeleteIndicator] [int] NOT NULL,
	[DeleteDate] [datetime] NOT NULL,
	[PurgeDate] [datetime] NOT NULL,
 CONSTRAINT [PK_GL_Star_SubLedger] PRIMARY KEY CLUSTERED 
(
	[SubLedger] ASC,
	[SubLedgerType] ASC,
	[SourceID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON, FILLFACTOR = 90, DATA_COMPRESSION = PAGE) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_PADDING OFF
GO
/****** Object:  Table [dbo].[RD_Monitor_GL]    Script Date: 5/30/13 1:04:49 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[RD_Monitor_GL]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[RD_Monitor_GL](
	[JDE_Date] [datetime] NOT NULL,
	[DWCR_Date] [datetime] NOT NULL,
	[DWCR_Timings] [int] NOT NULL,
	[DataMart_Date] [datetime] NOT NULL,
	[DataMart_timings] [int] NOT NULL,
 CONSTRAINT [PK_RD_Monito_GL] PRIMARY KEY CLUSTERED 
(
	[JDE_Date] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON, DATA_COMPRESSION = PAGE) ON [PRIMARY]
) ON [PRIMARY]
END
GO
/****** Object:  View [dbo].[GL_Star_Account]    Script Date: 5/30/13 1:04:49 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.views WHERE object_id = OBJECT_ID(N'[dbo].[GL_Star_Account]'))
EXEC dbo.sp_executesql @statement = N'
CREATE VIEW [dbo].[GL_Star_Account]
AS
SELECT     *
FROM         RD_Common.dbo.Star_Account

' 
GO
/****** Object:  View [dbo].[GL_Star_Account_Model]    Script Date: 5/30/13 1:04:49 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.views WHERE object_id = OBJECT_ID(N'[dbo].[GL_Star_Account_Model]'))
EXEC dbo.sp_executesql @statement = N'
CREATE VIEW [dbo].[GL_Star_Account_Model]
AS
SELECT      *
FROM         RD_Common.dbo.Star_Account_Model

' 
GO
/****** Object:  View [dbo].[GL_Star_BusinessUnit]    Script Date: 5/30/13 1:04:49 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.views WHERE object_id = OBJECT_ID(N'[dbo].[GL_Star_BusinessUnit]'))
EXEC dbo.sp_executesql @statement = N'
CREATE VIEW [dbo].[GL_Star_BusinessUnit]
AS
SELECT     *
FROM         RD_Common.dbo.Star_BusinessUnit

' 
GO
/****** Object:  View [dbo].[GL_Star_BusinessUnitSecurity]    Script Date: 5/30/13 1:04:49 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.views WHERE object_id = OBJECT_ID(N'[dbo].[GL_Star_BusinessUnitSecurity]'))
EXEC dbo.sp_executesql @statement = N'CREATE VIEW [dbo].[GL_Star_BusinessUnitSecurity]
AS
SELECT     *
FROM         RD_CommonWork.dbo.JDEBOBusinessUnitSecurity
' 
GO
/****** Object:  View [dbo].[GL_Star_Company]    Script Date: 5/30/13 1:04:49 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.views WHERE object_id = OBJECT_ID(N'[dbo].[GL_Star_Company]'))
EXEC dbo.sp_executesql @statement = N'
CREATE VIEW [dbo].[GL_Star_Company]
AS
SELECT     *
FROM         RD_Common.dbo.Star_Company

' 
GO
/****** Object:  View [dbo].[GL_Star_Dates]    Script Date: 5/30/13 1:04:49 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.views WHERE object_id = OBJECT_ID(N'[dbo].[GL_Star_Dates]'))
EXEC dbo.sp_executesql @statement = N'CREATE VIEW [dbo].[GL_Star_Dates]
AS
SELECT     *
FROM         RD_Common.dbo.Star_Dates
' 
GO
/****** Object:  View [dbo].[GL_Star_FiscalYear]    Script Date: 5/30/13 1:04:49 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.views WHERE object_id = OBJECT_ID(N'[dbo].[GL_Star_FiscalYear]'))
EXEC dbo.sp_executesql @statement = N'CREATE VIEW [dbo].[GL_Star_FiscalYear]
AS
SELECT     *
FROM         RD_Common.dbo.Star_FiscalYear
' 
GO
/****** Object:  View [dbo].[GL_Star_Ledger]    Script Date: 5/30/13 1:04:49 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.views WHERE object_id = OBJECT_ID(N'[dbo].[GL_Star_Ledger]'))
EXEC dbo.sp_executesql @statement = N'
CREATE VIEW [dbo].[GL_Star_Ledger]
AS
SELECT     
	   Cast(substring(UserdefinedCodesValues,9,2) + Cast(SourceID as char(5)) as char(10))  as ''LedgerTypeID'' ,
	   SourceID, 
	   Cast(Source as char(20)) as ''Source'', 
	   Cast(substring(UserdefinedCodesValues,9,2) as varchar(2)) as ''LedgerTypeCode'', 
	   Cast(Description01 as char(30)) as ''LedgerType'',
	   InsertIndicator,
	   InsertDate,
                ChangeIndicator,
                ChangeDate,
 	   DeleteIndicator,
	   DeleteDate,
	   PurgeDate
FROM     RD_CommonWork.dbo.JDEGSUserDefinedCodes
WHERE InstallSystemCode = ''09'' AND UserDefinedCode = ''LT''

' 
GO
SET ANSI_PADDING ON

GO
/****** Object:  Index [IX_Facts_AccountID]    Script Date: 5/30/13 1:04:49 PM ******/
IF NOT EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[GL_Star_Facts]') AND name = N'IX_Facts_AccountID')
CREATE NONCLUSTERED INDEX [IX_Facts_AccountID] ON [dbo].[GL_Star_Facts]
(
	[AccountID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
GO
/****** Object:  Index [IX_Facts_AIDID]    Script Date: 5/30/13 1:04:49 PM ******/
IF NOT EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[GL_Star_Facts]') AND name = N'IX_Facts_AIDID')
CREATE NONCLUSTERED INDEX [IX_Facts_AIDID] ON [dbo].[GL_Star_Facts]
(
	[AIDID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
GO
SET ANSI_PADDING ON

GO
/****** Object:  Index [IX_Facts_BusinessUnitID]    Script Date: 5/30/13 1:04:49 PM ******/
IF NOT EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[GL_Star_Facts]') AND name = N'IX_Facts_BusinessUnitID')
CREATE NONCLUSTERED INDEX [IX_Facts_BusinessUnitID] ON [dbo].[GL_Star_Facts]
(
	[BusinessUnitID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
GO
/****** Object:  Index [IX_Facts_CompanyNumberID]    Script Date: 5/30/13 1:04:49 PM ******/
IF NOT EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[GL_Star_Facts]') AND name = N'IX_Facts_CompanyNumberID')
CREATE NONCLUSTERED INDEX [IX_Facts_CompanyNumberID] ON [dbo].[GL_Star_Facts]
(
	[CompanyNumberID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
GO
/****** Object:  Index [IX_Facts_FiscalYearID]    Script Date: 5/30/13 1:04:49 PM ******/
IF NOT EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[GL_Star_Facts]') AND name = N'IX_Facts_FiscalYearID')
CREATE NONCLUSTERED INDEX [IX_Facts_FiscalYearID] ON [dbo].[GL_Star_Facts]
(
	[FiscalYearID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
GO
SET ANSI_PADDING ON

GO
/****** Object:  Index [IX_Facts_LedgerTypeID]    Script Date: 5/30/13 1:04:49 PM ******/
IF NOT EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[GL_Star_Facts]') AND name = N'IX_Facts_LedgerTypeID')
CREATE NONCLUSTERED INDEX [IX_Facts_LedgerTypeID] ON [dbo].[GL_Star_Facts]
(
	[LedgerTypeID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
GO
SET ANSI_PADDING ON

GO
/****** Object:  Index [IX_Facts_SubLedgerID]    Script Date: 5/30/13 1:04:49 PM ******/
IF NOT EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[GL_Star_Facts]') AND name = N'IX_Facts_SubLedgerID')
CREATE NONCLUSTERED INDEX [IX_Facts_SubLedgerID] ON [dbo].[GL_Star_Facts]
(
	[SubLedgerID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
GO
SET ANSI_PADDING ON

GO
/****** Object:  Index [missing_index_106]    Script Date: 5/30/13 1:04:49 PM ******/
IF NOT EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[GL_Star_Facts]') AND name = N'missing_index_106')
CREATE NONCLUSTERED INDEX [missing_index_106] ON [dbo].[GL_Star_Facts]
(
	[FiscalYearID] ASC,
	[LedgerTypeCode] ASC
)
INCLUDE ( 	[BusinessUnitID],
	[AIDID],
	[NetPosting01],
	[NetPosting02],
	[NetPosting03],
	[NetPosting04],
	[NetPosting05],
	[NetPosting06],
	[NetPosting07],
	[NetPosting08],
	[NetPosting09],
	[NetPosting10],
	[NetPosting11],
	[NetPosting12]) WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
GO
SET ANSI_PADDING ON

GO
/****** Object:  Index [missing_index_108]    Script Date: 5/30/13 1:04:49 PM ******/
IF NOT EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[GL_Star_Facts]') AND name = N'missing_index_108')
CREATE NONCLUSTERED INDEX [missing_index_108] ON [dbo].[GL_Star_Facts]
(
	[LedgerTypeCode] ASC
)
INCLUDE ( 	[BusinessUnitID],
	[AIDID],
	[FiscalYearID],
	[NetPosting01],
	[NetPosting02],
	[NetPosting03],
	[NetPosting04],
	[NetPosting05],
	[NetPosting06],
	[NetPosting07],
	[NetPosting08],
	[NetPosting09],
	[NetPosting10],
	[NetPosting11],
	[NetPosting12]) WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
GO
SET ANSI_PADDING ON

GO
/****** Object:  Index [missing_index_133]    Script Date: 5/30/13 1:04:49 PM ******/
IF NOT EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[GL_Star_Facts]') AND name = N'missing_index_133')
CREATE NONCLUSTERED INDEX [missing_index_133] ON [dbo].[GL_Star_Facts]
(
	[CompanyNumberID] ASC,
	[FiscalYearID] ASC,
	[LedgerTypeCode] ASC,
	[Object] ASC
)
INCLUDE ( 	[BusinessUnitID],
	[Balance07]) WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
GO
SET ANSI_PADDING ON

GO
/****** Object:  Index [missing_index_135]    Script Date: 5/30/13 1:04:49 PM ******/
IF NOT EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[GL_Star_Facts]') AND name = N'missing_index_135')
CREATE NONCLUSTERED INDEX [missing_index_135] ON [dbo].[GL_Star_Facts]
(
	[CompanyNumberID] ASC,
	[LedgerTypeCode] ASC,
	[Object] ASC
)
INCLUDE ( 	[BusinessUnitID],
	[FiscalYearID],
	[Balance07]) WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
GO
SET ANSI_PADDING ON

GO
/****** Object:  Index [missing_index_140]    Script Date: 5/30/13 1:04:49 PM ******/
IF NOT EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[GL_Star_Facts]') AND name = N'missing_index_140')
CREATE NONCLUSTERED INDEX [missing_index_140] ON [dbo].[GL_Star_Facts]
(
	[CompanyNumberID] ASC,
	[FiscalYearID] ASC,
	[LedgerTypeCode] ASC,
	[Object] ASC
)
INCLUDE ( 	[BusinessUnitID],
	[Subsidiary],
	[Balance07]) WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
GO
SET ANSI_PADDING ON

GO
/****** Object:  Index [missing_index_142]    Script Date: 5/30/13 1:04:49 PM ******/
IF NOT EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[GL_Star_Facts]') AND name = N'missing_index_142')
CREATE NONCLUSTERED INDEX [missing_index_142] ON [dbo].[GL_Star_Facts]
(
	[CompanyNumberID] ASC,
	[LedgerTypeCode] ASC,
	[Object] ASC
)
INCLUDE ( 	[BusinessUnitID],
	[FiscalYearID],
	[Subsidiary],
	[Balance07]) WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
GO
SET ANSI_PADDING ON

GO
/****** Object:  Index [missing_index_181]    Script Date: 5/30/13 1:04:49 PM ******/
IF NOT EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[GL_Star_Facts]') AND name = N'missing_index_181')
CREATE NONCLUSTERED INDEX [missing_index_181] ON [dbo].[GL_Star_Facts]
(
	[CompanyNumberID] ASC,
	[FiscalYearID] ASC,
	[LedgerTypeCode] ASC,
	[Object] ASC
)
INCLUDE ( 	[BusinessUnitID],
	[Subsidiary],
	[Balance01]) WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
GO
SET ANSI_PADDING ON

GO
/****** Object:  Index [missing_index_183]    Script Date: 5/30/13 1:04:49 PM ******/
IF NOT EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[GL_Star_Facts]') AND name = N'missing_index_183')
CREATE NONCLUSTERED INDEX [missing_index_183] ON [dbo].[GL_Star_Facts]
(
	[CompanyNumberID] ASC,
	[LedgerTypeCode] ASC,
	[Object] ASC
)
INCLUDE ( 	[BusinessUnitID],
	[FiscalYearID],
	[Subsidiary],
	[Balance01]) WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
GO
SET ANSI_PADDING ON

GO
/****** Object:  Index [missing_index_190]    Script Date: 5/30/13 1:04:49 PM ******/
IF NOT EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[GL_Star_Facts]') AND name = N'missing_index_190')
CREATE NONCLUSTERED INDEX [missing_index_190] ON [dbo].[GL_Star_Facts]
(
	[Object] ASC
)
INCLUDE ( 	[CompanyNumberID],
	[BusinessUnitID],
	[FiscalYearID],
	[LedgerTypeCode],
	[Subsidiary],
	[PriorYearCloseBalance],
	[Balance01],
	[PriorYearEndNetPosting],
	[BalanceForward]) WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
GO
SET ANSI_PADDING ON

GO
/****** Object:  Index [missing_index_259]    Script Date: 5/30/13 1:04:49 PM ******/
IF NOT EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[GL_Star_Facts]') AND name = N'missing_index_259')
CREATE NONCLUSTERED INDEX [missing_index_259] ON [dbo].[GL_Star_Facts]
(
	[FiscalYear] ASC,
	[LedgerTypeCode] ASC
)
INCLUDE ( 	[BusinessUnitID],
	[AccountID],
	[NetPosting05]) WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
GO
SET ANSI_PADDING ON

GO
/****** Object:  Index [missing_index_261]    Script Date: 5/30/13 1:04:49 PM ******/
IF NOT EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[GL_Star_Facts]') AND name = N'missing_index_261')
CREATE NONCLUSTERED INDEX [missing_index_261] ON [dbo].[GL_Star_Facts]
(
	[FiscalYear] ASC,
	[LedgerTypeCode] ASC
)
INCLUDE ( 	[BusinessUnitID],
	[AccountID],
	[NetPosting01]) WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
GO
SET ANSI_PADDING ON

GO
/****** Object:  Index [missing_index_263]    Script Date: 5/30/13 1:04:49 PM ******/
IF NOT EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[GL_Star_Facts]') AND name = N'missing_index_263')
CREATE NONCLUSTERED INDEX [missing_index_263] ON [dbo].[GL_Star_Facts]
(
	[FiscalYear] ASC,
	[LedgerTypeCode] ASC
)
INCLUDE ( 	[BusinessUnitID],
	[AccountID],
	[NetPosting02]) WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
GO
SET ANSI_PADDING ON

GO
/****** Object:  Index [missing_index_265]    Script Date: 5/30/13 1:04:49 PM ******/
IF NOT EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[GL_Star_Facts]') AND name = N'missing_index_265')
CREATE NONCLUSTERED INDEX [missing_index_265] ON [dbo].[GL_Star_Facts]
(
	[FiscalYear] ASC,
	[LedgerTypeCode] ASC
)
INCLUDE ( 	[BusinessUnitID],
	[AccountID],
	[NetPosting03]) WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
GO
SET ANSI_PADDING ON

GO
/****** Object:  Index [missing_index_267]    Script Date: 5/30/13 1:04:49 PM ******/
IF NOT EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[GL_Star_Facts]') AND name = N'missing_index_267')
CREATE NONCLUSTERED INDEX [missing_index_267] ON [dbo].[GL_Star_Facts]
(
	[FiscalYear] ASC,
	[LedgerTypeCode] ASC
)
INCLUDE ( 	[BusinessUnitID],
	[AccountID],
	[NetPosting04]) WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
GO
SET ANSI_PADDING ON

GO
/****** Object:  Index [missing_index_362]    Script Date: 5/30/13 1:04:49 PM ******/
IF NOT EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[GL_Star_Facts]') AND name = N'missing_index_362')
CREATE NONCLUSTERED INDEX [missing_index_362] ON [dbo].[GL_Star_Facts]
(
	[AccountID] ASC,
	[FiscalYear] ASC,
	[LedgerTypeCode] ASC
)
INCLUDE ( 	[BusinessUnitID],
	[NetPosting09]) WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
GO
SET ANSI_PADDING ON

GO
/****** Object:  Index [missing_index_377]    Script Date: 5/30/13 1:04:49 PM ******/
IF NOT EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[GL_Star_Facts]') AND name = N'missing_index_377')
CREATE NONCLUSTERED INDEX [missing_index_377] ON [dbo].[GL_Star_Facts]
(
	[AccountID] ASC,
	[FiscalYear] ASC,
	[LedgerTypeCode] ASC
)
INCLUDE ( 	[BusinessUnitID],
	[NetPosting08]) WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
GO
SET ANSI_PADDING ON

GO
/****** Object:  Index [missing_index_393]    Script Date: 5/30/13 1:04:49 PM ******/
IF NOT EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[GL_Star_Facts]') AND name = N'missing_index_393')
CREATE NONCLUSTERED INDEX [missing_index_393] ON [dbo].[GL_Star_Facts]
(
	[FiscalYear] ASC,
	[LedgerTypeCode] ASC
)
INCLUDE ( 	[BusinessUnitID],
	[AccountID],
	[NetPosting06]) WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
GO
SET ANSI_PADDING ON

GO
/****** Object:  Index [missing_index_395]    Script Date: 5/30/13 1:04:49 PM ******/
IF NOT EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[GL_Star_Facts]') AND name = N'missing_index_395')
CREATE NONCLUSTERED INDEX [missing_index_395] ON [dbo].[GL_Star_Facts]
(
	[FiscalYear] ASC,
	[LedgerTypeCode] ASC
)
INCLUDE ( 	[BusinessUnitID],
	[AccountID],
	[NetPosting07]) WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
GO
SET ANSI_PADDING ON

GO
/****** Object:  Index [missing_index_447]    Script Date: 5/30/13 1:04:49 PM ******/
IF NOT EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[GL_Star_Facts]') AND name = N'missing_index_447')
CREATE NONCLUSTERED INDEX [missing_index_447] ON [dbo].[GL_Star_Facts]
(
	[LedgerTypeCode] ASC
)
INCLUDE ( 	[AIDID],
	[FiscalYearID],
	[Balance07]) WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
GO
SET ANSI_PADDING ON

GO
/****** Object:  Index [missing_index_450]    Script Date: 5/30/13 1:04:49 PM ******/
IF NOT EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[GL_Star_Facts]') AND name = N'missing_index_450')
CREATE NONCLUSTERED INDEX [missing_index_450] ON [dbo].[GL_Star_Facts]
(
	[LedgerTypeCode] ASC,
	[CompanyNumberID] ASC
)
INCLUDE ( 	[AIDID],
	[FiscalYearID],
	[Balance07]) WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
GO
SET ANSI_PADDING ON

GO
/****** Object:  Index [_dta_index_GL_Star_FactsDetails_6_341576255__K13_K21_K16_K11_K8_K10_K7_K12_K9_K2_K24_K23_K30_27]    Script Date: 5/30/13 1:04:49 PM ******/
IF NOT EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[GL_Star_FactsDetails]') AND name = N'_dta_index_GL_Star_FactsDetails_6_341576255__K13_K21_K16_K11_K8_K10_K7_K12_K9_K2_K24_K23_K30_27')
CREATE NONCLUSTERED INDEX [_dta_index_GL_Star_FactsDetails_6_341576255__K13_K21_K16_K11_K8_K10_K7_K12_K9_K2_K24_K23_K30_27] ON [dbo].[GL_Star_FactsDetails]
(
	[GLDateID] ASC,
	[CompanyNumber] ASC,
	[LedgerTypeCode] ASC,
	[JournalEntryLineNumber] ASC,
	[DocumentCompany] ASC,
	[DocumentNumber] ASC,
	[SourceID] ASC,
	[LineExtensionCode] ASC,
	[DocumentType] ASC,
	[BusinessUnitID] ASC,
	[Subsidiary] ASC,
	[Object] ASC,
	[ExplanationDescription] ASC
)
INCLUDE ( 	[Amount]) WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
GO
SET ANSI_PADDING ON

GO
/****** Object:  Index [IX_Doctype]    Script Date: 5/30/13 1:04:49 PM ******/
IF NOT EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[GL_Star_FactsDetails]') AND name = N'IX_Doctype')
CREATE NONCLUSTERED INDEX [IX_Doctype] ON [dbo].[GL_Star_FactsDetails]
(
	[DocumentType] ASC,
	[GLPeriodNumber] ASC,
	[Century] ASC,
	[FiscalYear] ASC
)
INCLUDE ( 	[Account],
	[Amount]) WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
GO
/****** Object:  Index [IX_FactsDet_CheckDateID]    Script Date: 5/30/13 1:04:49 PM ******/
IF NOT EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[GL_Star_FactsDetails]') AND name = N'IX_FactsDet_CheckDateID')
CREATE NONCLUSTERED INDEX [IX_FactsDet_CheckDateID] ON [dbo].[GL_Star_FactsDetails]
(
	[CheckDateID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
GO
/****** Object:  Index [IX_FactsDet_GLDateID]    Script Date: 5/30/13 1:04:49 PM ******/
IF NOT EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[GL_Star_FactsDetails]') AND name = N'IX_FactsDet_GLDateID')
CREATE NONCLUSTERED INDEX [IX_FactsDet_GLDateID] ON [dbo].[GL_Star_FactsDetails]
(
	[GLDateID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
GO
/****** Object:  Index [IX_FactsDet_InvoiceDateID]    Script Date: 5/30/13 1:04:49 PM ******/
IF NOT EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[GL_Star_FactsDetails]') AND name = N'IX_FactsDet_InvoiceDateID')
CREATE NONCLUSTERED INDEX [IX_FactsDet_InvoiceDateID] ON [dbo].[GL_Star_FactsDetails]
(
	[InvoiceDateID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
GO
SET ANSI_PADDING ON

GO
/****** Object:  Index [IX_FactsDetails_AccountID]    Script Date: 5/30/13 1:04:49 PM ******/
IF NOT EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[GL_Star_FactsDetails]') AND name = N'IX_FactsDetails_AccountID')
CREATE NONCLUSTERED INDEX [IX_FactsDetails_AccountID] ON [dbo].[GL_Star_FactsDetails]
(
	[AccountID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
GO
/****** Object:  Index [IX_FactsDetails_AIDID]    Script Date: 5/30/13 1:04:49 PM ******/
IF NOT EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[GL_Star_FactsDetails]') AND name = N'IX_FactsDetails_AIDID')
CREATE NONCLUSTERED INDEX [IX_FactsDetails_AIDID] ON [dbo].[GL_Star_FactsDetails]
(
	[AIDID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
GO
SET ANSI_PADDING ON

GO
/****** Object:  Index [IX_FactsDetails_BusinessUnitID]    Script Date: 5/30/13 1:04:49 PM ******/
IF NOT EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[GL_Star_FactsDetails]') AND name = N'IX_FactsDetails_BusinessUnitID')
CREATE NONCLUSTERED INDEX [IX_FactsDetails_BusinessUnitID] ON [dbo].[GL_Star_FactsDetails]
(
	[BusinessUnitID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
GO
/****** Object:  Index [IX_FactsDetails_CompanyNumberID]    Script Date: 5/30/13 1:04:49 PM ******/
IF NOT EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[GL_Star_FactsDetails]') AND name = N'IX_FactsDetails_CompanyNumberID')
CREATE NONCLUSTERED INDEX [IX_FactsDetails_CompanyNumberID] ON [dbo].[GL_Star_FactsDetails]
(
	[CompanyNumberID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
GO
SET ANSI_PADDING ON

GO
/****** Object:  Index [IX_FactsDetails_LedgerTypeID]    Script Date: 5/30/13 1:04:49 PM ******/
IF NOT EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[GL_Star_FactsDetails]') AND name = N'IX_FactsDetails_LedgerTypeID')
CREATE NONCLUSTERED INDEX [IX_FactsDetails_LedgerTypeID] ON [dbo].[GL_Star_FactsDetails]
(
	[LedgerTypeID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
GO
SET ANSI_PADDING ON

GO
/****** Object:  Index [IX_FactsDetails_SubLedgerID]    Script Date: 5/30/13 1:04:49 PM ******/
IF NOT EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[GL_Star_FactsDetails]') AND name = N'IX_FactsDetails_SubLedgerID')
CREATE NONCLUSTERED INDEX [IX_FactsDetails_SubLedgerID] ON [dbo].[GL_Star_FactsDetails]
(
	[SubLedgerID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
GO
SET ANSI_PADDING ON

GO
/****** Object:  Index [missing_index_1]    Script Date: 5/30/13 1:04:49 PM ******/
IF NOT EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[GL_Star_FactsDetails]') AND name = N'missing_index_1')
CREATE NONCLUSTERED INDEX [missing_index_1] ON [dbo].[GL_Star_FactsDetails]
(
	[GLDateID] ASC
)
INCLUDE ( 	[BusinessUnitID],
	[AIDID],
	[AccountID],
	[Amount]) WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
GO
SET ANSI_PADDING ON

GO
/****** Object:  Index [missing_index_148]    Script Date: 5/30/13 1:04:49 PM ******/
IF NOT EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[GL_Star_FactsDetails]') AND name = N'missing_index_148')
CREATE NONCLUSTERED INDEX [missing_index_148] ON [dbo].[GL_Star_FactsDetails]
(
	[DocumentType] ASC,
	[DocumentNumber] ASC
)
INCLUDE ( 	[Amount]) WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
GO
SET ANSI_PADDING ON

GO
/****** Object:  Index [missing_index_237]    Script Date: 5/30/13 1:04:49 PM ******/
IF NOT EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[GL_Star_FactsDetails]') AND name = N'missing_index_237')
CREATE NONCLUSTERED INDEX [missing_index_237] ON [dbo].[GL_Star_FactsDetails]
(
	[SourceID] ASC,
	[DocumentCompany] ASC,
	[DocumentType] ASC,
	[DocumentNumber] ASC,
	[JournalEntryLineNumber] ASC,
	[LineExtensionCode] ASC,
	[LedgerTypeCode] ASC,
	[GLDateID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
GO
SET ANSI_PADDING ON

GO
/****** Object:  Index [missing_index_280]    Script Date: 5/30/13 1:04:49 PM ******/
IF NOT EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[GL_Star_FactsDetails]') AND name = N'missing_index_280')
CREATE NONCLUSTERED INDEX [missing_index_280] ON [dbo].[GL_Star_FactsDetails]
(
	[LedgerTypeCode] ASC,
	[GLPostedCode] ASC,
	[GLPeriodNumber] ASC
)
INCLUDE ( 	[BusinessUnitID],
	[AIDID],
	[DocumentType],
	[GLDateID],
	[Object],
	[Amount],
	[Ref1JEVouchInvEtc]) WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
GO
SET ANSI_PADDING ON

GO
/****** Object:  Index [missing_index_56]    Script Date: 5/30/13 1:04:49 PM ******/
IF NOT EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[GL_Star_FactsDetails]') AND name = N'missing_index_56')
CREATE NONCLUSTERED INDEX [missing_index_56] ON [dbo].[GL_Star_FactsDetails]
(
	[GLDateID] ASC,
	[LedgerTypeCode] ASC,
	[CompanyNumber] ASC
)
INCLUDE ( 	[AIDID],
	[Object],
	[Subsidiary],
	[Amount]) WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
GO
SET ANSI_PADDING ON

GO
/****** Object:  Index [missing_index_58]    Script Date: 5/30/13 1:04:49 PM ******/
IF NOT EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[GL_Star_FactsDetails]') AND name = N'missing_index_58')
CREATE NONCLUSTERED INDEX [missing_index_58] ON [dbo].[GL_Star_FactsDetails]
(
	[LedgerTypeCode] ASC,
	[CompanyNumber] ASC
)
INCLUDE ( 	[AIDID],
	[GLDateID],
	[Object],
	[Subsidiary],
	[Amount]) WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
GO
SET ANSI_PADDING ON

GO
/****** Object:  Index [missing_index_75]    Script Date: 5/30/13 1:04:49 PM ******/
IF NOT EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[GL_Star_FactsDetails]') AND name = N'missing_index_75')
CREATE NONCLUSTERED INDEX [missing_index_75] ON [dbo].[GL_Star_FactsDetails]
(
	[LedgerTypeID] ASC,
	[GLDateID] ASC
)
INCLUDE ( 	[BusinessUnitID],
	[AIDID],
	[Amount]) WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
GO
SET ANSI_PADDING ON

GO
/****** Object:  Index [missing_index_76]    Script Date: 5/30/13 1:04:49 PM ******/
IF NOT EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[GL_Star_FactsDetails]') AND name = N'missing_index_76')
CREATE NONCLUSTERED INDEX [missing_index_76] ON [dbo].[GL_Star_FactsDetails]
(
	[GLDateID] ASC,
	[LedgerTypeCode] ASC,
	[CompanyNumber] ASC
)
INCLUDE ( 	[AccountID],
	[Object],
	[Subsidiary],
	[Amount]) WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
GO
SET ANSI_PADDING ON

GO
/****** Object:  Index [missing_index_78]    Script Date: 5/30/13 1:04:49 PM ******/
IF NOT EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[GL_Star_FactsDetails]') AND name = N'missing_index_78')
CREATE NONCLUSTERED INDEX [missing_index_78] ON [dbo].[GL_Star_FactsDetails]
(
	[LedgerTypeCode] ASC,
	[CompanyNumber] ASC
)
INCLUDE ( 	[AccountID],
	[GLDateID],
	[Object],
	[Subsidiary],
	[Amount]) WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
GO
SET ANSI_PADDING ON

GO
/****** Object:  Index [missing_index_91]    Script Date: 5/30/13 1:04:49 PM ******/
IF NOT EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[GL_Star_FactsDetails]') AND name = N'missing_index_91')
CREATE NONCLUSTERED INDEX [missing_index_91] ON [dbo].[GL_Star_FactsDetails]
(
	[GLDateID] ASC,
	[CompanyNumber] ASC
)
INCLUDE ( 	[AccountID],
	[Object],
	[Subsidiary],
	[Amount]) WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
GO
SET ANSI_PADDING ON

GO
/****** Object:  Index [missing_index_93]    Script Date: 5/30/13 1:04:49 PM ******/
IF NOT EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[GL_Star_FactsDetails]') AND name = N'missing_index_93')
CREATE NONCLUSTERED INDEX [missing_index_93] ON [dbo].[GL_Star_FactsDetails]
(
	[CompanyNumber] ASC
)
INCLUDE ( 	[AccountID],
	[GLDateID],
	[Object],
	[Subsidiary],
	[Amount]) WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
GO
SET ANSI_PADDING ON

GO
/****** Object:  Index [missing_index_96]    Script Date: 5/30/13 1:04:49 PM ******/
IF NOT EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[GL_Star_FactsDetails]') AND name = N'missing_index_96')
CREATE NONCLUSTERED INDEX [missing_index_96] ON [dbo].[GL_Star_FactsDetails]
(
	[AIDID] ASC,
	[CompanyNumber] ASC,
	[Object] ASC,
	[Subsidiary] ASC
)
INCLUDE ( 	[GLDateID],
	[Amount]) WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
GO
SET ANSI_PADDING ON

GO
/****** Object:  Index [UnClustered_Object]    Script Date: 5/30/13 1:04:49 PM ******/
IF NOT EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[GL_Star_FactsDetails]') AND name = N'UnClustered_Object')
CREATE NONCLUSTERED INDEX [UnClustered_Object] ON [dbo].[GL_Star_FactsDetails]
(
	[Account] ASC,
	[DocumentType] ASC,
	[Object] ASC,
	[Amount] ASC,
	[GLPeriodNumber] ASC,
	[Century] ASC,
	[FiscalYear] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
GO
SET ANSI_PADDING ON

GO
/****** Object:  Index [IX_SubLedger_SubLedgerID]    Script Date: 5/30/13 1:04:49 PM ******/
IF NOT EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[GL_Star_SubLedger]') AND name = N'IX_SubLedger_SubLedgerID')
CREATE NONCLUSTERED INDEX [IX_SubLedger_SubLedgerID] ON [dbo].[GL_Star_SubLedger]
(
	[SubLedgerID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
GO
SET ANSI_PADDING ON

GO
/****** Object:  Index [missing_index_184]    Script Date: 5/30/13 1:04:49 PM ******/
IF NOT EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[GL_Star_SubLedger]') AND name = N'missing_index_184')
CREATE NONCLUSTERED INDEX [missing_index_184] ON [dbo].[GL_Star_SubLedger]
(
	[SourceID] ASC,
	[SubLedgerType] ASC
)
INCLUDE ( 	[SubLedger]) WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
GO
